<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0 user-scalable=yes">
    <link href="css/jquery.mobile-1.2.0.min.css" rel="stylesheet" type="text/css" />
    <link href="css/common.css" rel="stylesheet" />
    <link href="css/waterfall.css" rel="stylesheet" />
    <script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="js/jquery.mobile-1.2.0.min.js" type="text/javascript"></script>
    <script src="js/waterfall.js"></script>
    <script src="js/Oup.Http.URL.js"></script>
    <script src="js/config.js"></script>
    <script type="text/javascript">
        var opt = {
            getResource: function (index, render) {
                GetList(render);
            },
            auto_imgHeight: true,
            insert_type: 1,
            column_width: 100,
            column_space: 2
        };
        var pageIndex = 1;
        var isFirst = true;
        function GetList(render) {
            //alert($.mobile.showPageLoadingMsg);
            $.mobile.showPageLoadingMsg('b', "正在加载");
            //var key = decodeURIComponent(Oup.Http.URL.getQueryString("key"));
            var urlContent = window.HtmlContent.getContent();
            var key=Oup.Http.URL.getString(urlContent,'key');
            //alert(location.href);
            $.ajax({
                type: "get",
                async: true,
                url: apihost + "/product/list",
                dataType: "json",
                ceche: true,
                data: { page: pageIndex, mod: "search", act: "list", keywords: key, cut: 1, simg_width: 90 },
                jsonp: "data",//服务端用于接收callback调用的function名的参数
                jsonpCallback: "success_jsonpCallback",//callback的function名称
                success: function (json) {
                    pageIndex++;
                    var result = "";
                    if (json.data.length == 0 && isFirst) {
                        $('#container').html('<div class="empty">没有搜索结果</div>');
                    } else {
                        for (var i = 0; i < json.data.length; i++) {
                            var d = json.data[i];
                            result += '<div class="cell">';
                            result += '<a val="' + d.s_id + '" name="produce" href="#">';
                            result += '<img src="' + d.s_pic_wap_small + '" />';
                            //result += '<p class="title">' + d.s_short_name + '</p>';
                            result += '</a></div>';
                        }
                        if (render == null) {
                            $('#container').html(result);
                            $('#container').waterfall(opt);
                        } else {
                            render($(result));
                        }
                        $('#container').isResize(true);
                    }
                    isFirst = false;
                    $.mobile.hidePageLoadingMsg();
                },
                error: function () {
                    $.mobile.hidePageLoadingMsg();
                }
            });
        }
        $(function () {
            GetList(null);
            $("a[name='produce']").live("click", function () {
                $('#container').isResize(false);
                $.waterfall.isScroll = false;
                //$.mobile.changePage('detail.html?id=' + $(this).attr("val"), { changeHash: true });
                location.href = 'detail.html?id=' + $(this).attr("val");
            });

            $(window).bind('scroll', function () {
                if ($("#rq_ProductDetail").length == 0 && $("div[role='banner']").length == 1) {
                    $.waterfall.isScroll = true;
                } else {
                    $.waterfall.isScroll = false;
                }
            });
        });
    </script>
    <style type="text/css">
        #title
        {
            text-align: center;
            color: #006699;
            font-weight: bold;
            font-size: 16px;
            background-color: #CCCCCC;
            margin-top: 5px;
            padding: 10px 10px 20px 10px;
        }

        .title
        {
            font-size: 12px;
        }
    </style>
</head>
<body>
    <div id="rq_ListTemp" style="display: none;"></div>
    <div data-role="page" id="searchresult">
        <div data-theme="b" data-role="header" class="ui-header ui-bar-b" role="banner" data-position="fixed" style="position: fixed; border-width: 0px 0px 1px;">
            <!--<h1 class="ui-title" role="heading" aria-level="1">搜索结果</h1>
                <a onclick="history.go(-1);" data-icon="arrow-l" href="#" class="ui-btn-left ui-btn ui-btn-up-a ui-shadow ui-btn-corner-all ui-btn-icon-left" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-theme="a">
                    <span class="ui-btn-inner ui-btn-corner-all">
                        <span class="ui-btn-text">返回</span>
                        <span class="ui-icon ui-icon-arrow-l ui-icon-shadow">&nbsp;</span>
                    </span>
                </a>-->
            <div class="logo" style="float: left; text-align: center; vertical-align: middle; height: 40px; line-height: 40px; width: 100%;">
                搜索结果
            </div>
            <a data-rel="back" href="#" data-role="button" data-inline="true" data-mini="true" data-theme="b">返回</a>
        </div>
        <div id="container" role="main" data-role="content">
        </div>
        <div data-role="footer" class="ui-footer ui-bar-a" role="contentinfo" data-position="fixed" style="position: fixed;">
            <div data-role="navbar" data-iconpos="top">
                <ul>
                    <li>
                        <a data-ajax="false" href="index.html" data-theme="b" data-icon="headerbtn6">每日推荐
                        </a>
                    </li>
                    <li>
                        <a data-ajax="false" href="list.html" data-theme="b" data-icon="headerbtn1">卖场
                        </a>
                    </li>
                    <li>
                        <a data-ajax="false" href="my.html" data-theme="b" data-icon="headerbtn2">我的
                        </a>
                    </li>
                    <li>
                        <a href="#" data-theme="b" data-icon="headerbtn3" class="ui-btn-active">搜索
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</body>
</html> 